What Is Node.js and Why Use It?
Now before diving into some NodeJS code, let’s do a high level overview of what NodeJS actually is, what we use it for and why we use Node instead of other technologies.
So, the official definition is that NodeJS is a JavaScript Runtime built on Google’s open-source V8 JavaScript engine.
Now, what does that actually mean? Well, let’s start by trying to understand what the JavaScript Runtime and the V8 engine actually are.
So, you have probably already used JavaScript before and it was probably always just inside a browser, right? Because any browser natively understands HTML, CSS, and JavaScript and no matter if you write vanilla JavaScript or some JavaScript framework like React or Angular code, that’s all just JavaScript that gets executed right in the browser.
So, in this case, the browser is then the JavaScript Runtime. But, what if we could take JavaScript out of the browser and simply execute or JavaScript code somewhere else without all the restrictions that we have in the browser? Well, it turns out that we actually can. And the solution for this, as you can guess, is called NodeJS and so Node JS is just another JavaScript Runtime.
It’s just like a container, like an environment, in which a program written in JavaScript can be executed, but outside of any browser whatsoever. All right, it’s actually a bit more complex than this, of course, but for now, this is enough.
Now, who actually does execute the code if not the browser? And that’s where the V8 engine developed by Google comes into play. Because that is exactly where JavaScript code will be parsed and run in NodeJS, okay?
So, I hope that now the definition of NodeJS being a JavaScript Runtime on the V8 JavaScript engine makes a lot more sense and again, this is just a very high level overview of what Node is and how it works.
We are gonna go into a lot of detail about how Node really works behind the scenes right in the next section, but at this point, I just want you to get a quick overview so that you can start learning the fundamentals of NodeJS in practice throughout this section.